package com.cplatform.spring.dynamicproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

public class Client {
    public static void main(String[] args) {
        System.getProperties().put("sun.misc.ProxyGenerator.saveGeneratedFiles", "true");
        Subject realSubject = new RealSubject();
        InvocationHandler invocationHandler = new InvocationHandlerImpl(realSubject);
        Subject subject = (Subject)Proxy.newProxyInstance(ClassLoader.getSystemClassLoader(), new Class[]{Subject.class}, invocationHandler);
        Class<?>[] interfaces = subject.getClass().getInterfaces();
        for (Class c :interfaces){
            System.out.println(c.getName());
        }
        subject.doSth("哈哈哈");
    }
}
